import {  getUserInfo } from '@/api/login/login'
import { actionType } from './constants'

function changeUserInfoAction(data){
    return {
        type:actionType.CHANGE_USERINFO,
        userInfo:data
    }
}


export const getUserInfoAction = (data) => {
    return dispatch => {
        getUserInfo().then(res=>{
            dispatch(changeUserInfoAction(res.profile))
        }).catch()
    }
}

//以后都这样写
export const changeUserInfo = (data) => {
    return dispatch => {
        dispatch({
            type:actionType.CHANGE_USERINFO,
            userInfo:data
        })
    }
}